<?php

namespace JsonLowCode\UI;

use JsonLowCode\Traits\Slots\HasSlotAction;
use JsonLowCode\Traits\Slots\HasSlotIcon;

/**
 * NPopconfirm
 * @method static PopConfirm make(mixed $children = null) PopConfirm组件
 */
class PopConfirm extends Popover
{
    protected string $componentName = "NPopconfirm";

    use HasSlotAction, HasSlotIcon;

    public function __construct(mixed $children = null)
    {
        parent::__construct();
        $this->children($children);
    }

    /**
     * 是否显示图标
     * @param bool|string $bool
     * @return $this
     */
    public function showIcon(bool|string $bool = true): static
    {
        return $this->prop('showIcon', $bool);
    }

    /**
     * 取消按钮文字
     * @param string $text
     * @return $this
     */
    public function negativeText(string $text = "取消"): static
    {
        return $this->prop('negativeText', $text);
    }

    /**
     * 确定按钮文字
     * @param string $text
     * @return $this
     */
    public function positiveText(string $text = "确定"): static
    {
        return $this->prop('positiveText', $text);
    }

    /**
     * 取消按钮的属性
     * @param string|array $props
     * @return $this
     */
    public function negativeButtonProps(string|array $props = ""): static
    {
        return $this->prop('negativeButtonProps', $props);
    }

    /**
     * 确定按钮的属性
     * @param string|array $props
     * @return $this
     */
    public function positiveButtonProps(string|array $props = ""): static
    {
        return $this->prop('positiveButtonProps', $props);
    }


    /**
     *  点击确定的回调函数
     * @param string $value  () => boolean | Promise<boolean> | any
     * @return $this
     */
    public function onPositiveClick(string $value = "()=>{}"): static
    {
        return $this->events('onPositiveClick', $value);
    }

    /**
     * 点击确定的回调函数
     * @param string $value  () => boolean | Promise<boolean> | any
     * @return $this
     */
    public function onNegativeClick(string $value = "()=>{ }"): static
    {
        return $this->events('onNegativeClick', $value);
    }

}
